<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-wrap align-stretch benben-position-layout flex footprint_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub footprint_fd0_0'>
				<view class='flex flex-wrap align-center footprint_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  footprint_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='footprint_fd0_0_c1_c0'>我的足迹</text>
				</view>
				<view @click='is_edit=!is_edit' class='flex align-center justify-end footprint_fd0_0_c2'>
					<text class='footprint_fd0_0_c2_c0' v-if="is_edit===false">编辑</text>
					<text
						class='footprint_fd0_0_c2_c0_1' v-if="is_edit===true">完成</text>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="!isShow">
			<u-loading size="36" color="#4177DD"></u-loading>
			<view class="loading_text">加载中</view>
		</view>
		
		<view class="footprint_content" v-else>
			<benben-goods-footprint :is-editor.sync='is_edit' :goods-list.sync='dataList' :goods-id.sync='shop_id'
				v-model='goods_ids' @handleDel="deteleFunc()" @handleGoods="jumpFunc()">
			</benben-goods-footprint>
			<u-loadmore v-if="last_page > 1" style="padding: 24rpx 0;width: 100%;" :status="status"
				:icon-type="iconType" :load-text="loadText" />
			<view class="noData" v-if="dataList.length == 0">
				<image src="/static/empty/no.png"></image>
				<view>暂无足迹商品~</view>
			</view>
		</view>

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				"dataList": [],
				"is_edit": false,
				"shop_id": "",
				"goods_ids": "",
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				"isShow": false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = false;
			this.dataListFunc()
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = false;
			this.dataListFunc()
		},
		onReachBottom(e) {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
					
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.dataListFunc();
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			//获取足迹列表
			dataListFunc() {
				this.$api.post(global.apiUrls.post6437cfcacc635, {
					page: this.page
				}).then(res => {
					uni.stopPullDownRefresh();
					this.isShow = true;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.dataList = res.data.data.data;
						} else {
							this.dataList = this.dataList.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			//删除足迹
			deteleFunc() {
				this.$api.post(global.apiUrls.post6437cfe5d0107, {
					foot_id: this.goods_ids
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						this.is_edit = false
						this.page = 1;
						this.is_pull = true;
						this.isShow = false;
						this.dataListFunc()
					}
				})
			},
			//点击商品
			jumpFunc() {
				this.$urouter.navigateTo(`/pages/homepage/shopDetail/shopDetail?id=${this.shop_id}`);
			}
		}
	};
</script>
<style lang="scss" scoped>
	.footprint_content {
		padding: 0 32rpx;
	}
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto !important;
	}

	.footprint_flex_0 {
		background: #fff;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.footprint_fd0_0_c2_c0_1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.footprint_fd0_0_c2_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.footprint_fd0_0_c2 {
		width: 180rpx;
	}

	.footprint_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.footprint_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.footprint_fd0_0_c0 {
		width: 180rpx;
	}

	.footprint_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}
</style>